<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:cc="http://xmlns.jcp.org/jsf/composite"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://xmlns.jcp.org/jsf/core">
    <cc:interface
        id = "calendarViewInterface"
        rendered="true">
        <cc:attribute
            default="true"
            id = "calendarViewRenderSharingFormParameter"
            name = "renderSharingForm"
            required = "true"
            type = "java.lang.Boolean" />
        <cc:attribute 
            default = "true"
            id = "calendarViewCalendarRenderDeleteButtonParameter"
            name = "renderDeleteButton" 
            required = "true"
            type = "java.lang.Boolean" />
        <cc:attribute
            id = "calendarViewCalendarViewControllerBeanParameter"
            name = "calendarViewControllerBean"
            required = "true"
            type = "assisisw.smartcal.webuisubsystem.managedbean.calendar.AbstractCalendarControllerBean"/>
        <cc:attribute 
            name = "componentToUpdateAfterOk"
            required = "true"
            type = "java.lang.String" />
        <cc:attribute 
            name = "endorsedParentComponent" 
            required = "true"
            type = "java.lang.String" />
    </cc:interface>
    <cc:implementation
        id = "calendarViewImplementation"
        rendered = "true" >
        <h:form 
            id = "calendarViewForm"
            prependId = "false"
            rendered = "true" 
            title = "Calendar Info" >
            <p:panel 
                id = "calendarViewCalendarGeneralDataBox" >
                <div class = "genericTableRow" >
                    <p:outputLabel 
                        for = "calendarNameField" 
                        id = "calendarNameLabel" 
                        transient = "true" 
                        value ="Calendar name :" />
                    <p:inputText 
                        disabled = "false" 
                        id = "calendarNameField"
                        immediate="true" 
                        maxlength = "15"
                        placeholder = "calendar name" 
                        readonly = "#{not cc.attrs.calendarViewControllerBean.calendarEditable}"
                        rendered="true" 
                        required = "true"
                        requiredMessage="Name is required !"
                        type = "text" 
                        value="#{cc.attrs.calendarViewControllerBean.managedCalendar.name}"/>
                </div>
                <div class = "genericTableRow" >
                    <p:outputLabel 
                        for = "calendarColorPicker"
                        id = "calendarColorLabel"
                        transient = "true"
                        value = "Calendar color :" />
                    <p:colorPicker 
                        id = "calendarColorPicker" 
                        rendered="#{cc.attrs.calendarViewControllerBean.calendarEditable}"
                        required="true"
                        requiredMessage="Color is required !"
                        value = "#{cc.attrs.calendarViewControllerBean.managedCalendar.color}" />
                </div>
                <div class="genericTableRow">
                    <p:outputLabel
                        for = "calendarVisibleCheckBox"
                        id  = "calendarVisibilityLabel"
                        rendered="#{cc.attrs.calendarViewControllerBean.calendarEditable}"
                        transient = "true"
                        value = "Visible :"/>
                    <p:selectBooleanCheckbox
                        id = "calendarVisibleCheckBox"
                        rendered="#{cc.attrs.calendarViewControllerBean.calendarEditable}"
                        value="#{cc.attrs.calendarViewControllerBean.managedCalendar.visible}"/>
                </div>
            </p:panel>
            <p:panel id = "calendarViewCalendarSharingBox">
                <div class = "genericTableRow" >
                    <p:dataScroller 
                        id = "calendarViewPeopleWhoCanAccessDataScoller" 
                        rendered="#{cc.attrs.renderSharingForm}"
                        value = "#{cc.attrs.calendarViewControllerBean.managedCalendar.peopleWhoCanAccess}" 
                        var = "user" 
                        widgetVar = "calendarViewPeopleWhoCanAccessDataScoller" >
                        <f:facet 
                            id = "calendarViewNotificationDataScrollerHeader"
                            name="header" 
                            rendered="true" >
                            People who can see this Calendar :
                        </f:facet>
                        <h:form>
                            #{user.mail}
                        </h:form>
                    </p:dataScroller>
                </div>
                <div class = "genericTableRow" >
                    <h:outputLabel 
                        for = "calendarViewNewSharingInputText" 
                        id = "calendarViewNewSharingLabel" value = "Add a sharing :" 
                        rendered="#{cc.attrs.renderSharingForm and cc.attrs.calendarViewControllerBean.calendarEditable}"/>
                    <p:inputText 
                        id = "calendarViewNewSharingInputText" 
                        immediate="true"
                        maxlength = "20"
                        placeholder = "mail of the user with which share this calendar"
                        rendered="#{cc.attrs.renderSharingForm and cc.attrs.calendarViewControllerBean.calendarEditable}"
                        value = "#{cc.attrs.calendarViewControllerBean.newSharedMail}" >
                        <p:ajax 
                            event="valueChange" 
                            update = "calendarViewNewSharingInputText" />
                    </p:inputText>
                    <p:commandButton 
                        id = "calendarViewNewSharingButton" 
                        rendered = "#{cc.attrs.renderSharingForm and cc.attrs.calendarViewControllerBean.calendarEditable}"
                        type = "submit"
                        value = "Share !" >
                        <p:ajax 
                            async = "true"
                            disabled="false"
                            event="click"
                            listener = "#{cc.attrs.calendarViewControllerBean.calendarViewShareCommand ()}" 
                            update = "calendarViewPeopleWhoCanAccessDataScoller" />
                    </p:commandButton>
                </div>
            </p:panel>
            <p:panel id = "calendarViewCommandsBox">
                <div class = "genericTableRow" >
                    <p:commandButton 
                        id = "deleteCalendarButton" 
                        onclick="PF('#{cc.attrs.endorsedParentComponent}').hide()"
                        rendered = "#{cc.attrs.renderDeleteButton and cc.attrs.calendarViewControllerBean.calendarEditable}" 
                        type="submit"
                        value = "Delete" >
                        <p:ajax
                            async = "true"
                            disabled = "false"
                            event = "click"
                            immediate = "true"
                            listener = "#{cc.attrs.calendarViewControllerBean.calendarViewDeleteCommand ()}"
                            update = "#{cc.attrs.componentToUpdateAfterOk}" />
                    </p:commandButton>
                    <p:commandButton 
                        ajax="true"
                        onclick = "PF('#{cc.attrs.endorsedParentComponent}').hide()"
                        rendered = "#{cc.attrs.calendarViewControllerBean.calendarEditable}"
                        type = "submit" 
                        validateClient = "true" 
                        value = "Ok" >
                        <p:ajax 
                            async = "true"
                            disabled = "false"
                            event = "click"
                            listener = "#{cc.attrs.calendarViewControllerBean.calendarViewConfirmationCommand ()}" 
                            process="@form"
                            update = "#{cc.attrs.componentToUpdateAfterOk},myGrowl"/>
                    </p:commandButton>
                    <p:growl 
                                    sticky="false" 
                                    showDetail="true" 
                                    showSummary="true" id ="myGrowl" 
                                    autoUpdate="true" 
                                    widgetVar="myGrowl" />       
                </div>
            </p:panel>
        </h:form>
    </cc:implementation>
</html>